package com.yc.boot.train.api;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yc.boot.common.model.ExcelAlias;
import com.yc.boot.common.model.response.Outcome;
import com.yc.boot.common.utils.ExcelUtil;
import com.yc.boot.train.business.CourseFeedbackBussiness;
import com.yc.boot.train.model.find.GradeFeedBack;
import com.yc.boot.train.model.find.GradeManage;
import com.yc.boot.train.model.find.IPageGradeFeedback;
import com.yc.boot.train.model.find.IPageGradeManage;
import com.yc.boot.train.model.update.UpdataGradeManage;
import com.yc.boot.train.model.update.UpdateGradeFeedback;
import com.yc.boot.work.model.find.TestPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * Create with IntelliT IDEA
 *
 * @Author: zhengmingzhe
 * @Date: 2022/01/06/15:31
 * @Description:
 */
@RestController
@Api(tags = "课程信息查看反馈页面接口")
@RequestMapping("/feedback")
public class CourseFeedbackApi {
    @Resource
    private CourseFeedbackBussiness courseFeedbackBussiness;

    @GetMapping("/queryGradeFeedback")
    @ApiOperation("获取分数回馈页面信息")
    public Outcome<IPage<GradeFeedBack>> queryGradeFeedback(IPageGradeFeedback page){
        return Outcome.success(courseFeedbackBussiness.queryGradeFeedback(page));
    }

    @PutMapping("/updateGradeFeedback")
    @ApiOperation("修改分数回馈信息项")
    public Outcome updateGradeFeedback(@RequestBody @Valid UpdateGradeFeedback param){
        return courseFeedbackBussiness.updateGradeFeedback(param);
    }
    public void downExcl(IPageGradeFeedback page) {
        IPage<GradeFeedBack> pages = courseFeedbackBussiness.queryGradeFeedback(page);
        ExcelUtil.downExcel(pages.getRecords(),
                CollUtil.newArrayList(ExcelAlias.makeAlias("id", "主键"),
                        ExcelAlias.makeAlias("createBy", "创建人"),
                        ExcelAlias.makeAlias("createTime", "创建时间"),
                        ExcelAlias.makeAlias("updateBy", "修改人"),
                        ExcelAlias.makeAlias("updateTime", "修改时间"),
                        ExcelAlias.makeAlias("isDelete", "是否删除"),
                        ExcelAlias.makeAlias("name", "名称"),
                        ExcelAlias.makeAlias("status", "状态")));
    }
}
